package View;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;


public class Home extends JPanel {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -4092886805638826148L;
	private JPanel header = new JPanel();
	private JPanel content = new JPanel();
	//private JPanel content2 = new JPanel();
	//private JPanel content3 = new JPanel();
	private JPanel sidebar = new JPanel(new GridBagLayout());

	public Home(){
		
		super(new GridBagLayout());
		
		GridBagConstraints con = new GridBagConstraints();
		
		header.setBackground(Color.gray);
		con.fill = GridBagConstraints.BOTH;
		con.weightx = 0.05;
		con.weighty = 0.05;
		con.gridx = 0;
		con.gridy = 0;
		con.gridwidth = 4;
		this.add(header,con);
				
		content.setBackground(Color.black);
		content.setMinimumSize(new Dimension(240,120));
		content.setPreferredSize(new Dimension(240,120));
		con.fill = GridBagConstraints.BOTH;
		con.weightx = 1.05;
		con.weighty = 1.05;
		con.gridx = 0;
		con.gridy = 1;
		con.gridwidth = 3;
		this.add(content,con);
		
		/*content2.setBackground(Color.red);
		content2.setMinimumSize(new Dimension(240,120));
		content2.setPreferredSize(new Dimension(240,120));
		con.fill = GridBagConstraints.BOTH;
		con.weightx = 0.7;
		con.weighty = 0.7;
		con.gridx = 1;
		con.gridy = 1;
		con.gridwidth = 1;
		this.add(content2,con);
		
		content3.setBackground(Color.black);
		content3.setMinimumSize(new Dimension(240,120));
		content3.setPreferredSize(new Dimension(240,120));
		con.fill = GridBagConstraints.BOTH;
		con.weightx = 0.7;
		con.weighty = 0.7;
		con.gridx = 2;
		con.gridy = 1;
		con.gridwidth = 1;
		this.add(content3,con);*/
		
		this.setsidebar(sidebar, "preferiti");
		sidebar.setMinimumSize(new Dimension(240,120));
		sidebar.setPreferredSize(new Dimension(240,120));
		con.fill = GridBagConstraints.BOTH;
		con.weightx = 0.35;
		con.weighty = 0.35;
		con.gridx = 3;
		con.gridy = 1;
		con.gridwidth = 1;
		this.add(sidebar,con);
       
	}
	
	private JPanel setsidebar(JPanel panel, String tit){
		
		GridBagConstraints c = new GridBagConstraints();
		
		JPanel titolo = new JPanel();
		titolo.setBackground(new Color(191,134,79));
		titolo.setBorder(BorderFactory.createLineBorder(Color.white));
		c.fill = GridBagConstraints.BOTH;
		c.weightx = 1;
		c.weighty = 0.05;
		c.gridx = 0;
		c.gridy = 0;
		c.gridwidth = 2;
		JLabel lab = new JLabel(tit);
		lab.setFont(new Font("Verdana",Font.PLAIN,14));
		lab.setForeground(Color.white);
		titolo.add(lab);
		panel.add(titolo,c);
		
		for(int i=0; i<5; i++){
			JPanel x = new JPanel(new FlowLayout(FlowLayout.LEFT));
			x.setBackground(new Color(207,149,129));
			x.setBorder(BorderFactory.createLineBorder(Color.white));
			c.fill = GridBagConstraints.BOTH;
			c.weightx = 1;
			c.weighty = 0.5;
			c.gridx = 0;
			c.gridy = i+1;
			JLabel l1 = new JLabel(Clio.createImageIcon("images/button1.png"));
			l1.setMaximumSize(new Dimension(80,50));
			l1.setPreferredSize(new Dimension(80,50));
			JLabel l2 = new JLabel("testo fuffo");
			x.add(l1);
			x.add(l2);
			panel.add(x,c);
		}
		return panel;
		
	}

	

}
